export class AudioPoolService {
  private instances: WechatMiniprogram.InnerAudioContext[];

  constructor(src: string, poolSize = 5) {
    this.instances = Array.from({ length: poolSize }, () => {
      const instance = wx.createInnerAudioContext({ useWebAudioImplement: true });
      instance.src = src;
      return instance;
    });
  }
  play() {
    const availableInstance = this.instances.find(ins => ins.paused);
    availableInstance?.play();
  }
}
